/**
 * Contains all the important catched exceptions
 * 
 * @author remo.lemma@lu.unisi.ch and patrick.zulian@lu.unisi.ch
 */

package ch.unisi.inf.projects.java.uom.exceptions;

public enum UOMExceptions {

	// UOM Exceptions
	/** Internal Error */
	DATABASE_INTERNAL_ERROR(4000),
	/** The given category does not exist */
	CATEGORY_NOT_EXIST(4001),
	/** Malformed data detected in the database */
	MALFORMED_DATA(4002),
	/** The reference to which we are pointing does not exist anymore */
	REFERENCE_NOT_EXIST(4003),
	/** The database is not valid */
	DATABASE_IS_NOT_VALID(4004),
	
	// Derby Apache Exceptions
	/** The database already exists */
	DB_EXISTS(40000, "XJ004"),
	/** The database is shutting down correctly */
	DB_SHUTDOWN(50000, "XJ015"),
	/** The given table does not exist */
	TABLE_NOT_EXIST(30000, "42X05");
	
	/** State for this error */
	private final String state;
	
	/** Code for this error */
	private final int code;
	
	/**
	 * Constructor
	 * @param code the error's code
	 * @param state for this error
	 */
	UOMExceptions (int code, String state)
	{
		this.code = code;
		this.state = state;
	}
	
	/**
	 * Constructor (empty error message)
	 * @param code the error's code
	 */
	UOMExceptions (int code)
	{
		this(code, "");
	}
	
	/**
	 * Returns the code
	 * @return the code
	 */
	public int code()
	{
		return this.code;
	}
	
	/**
	 * Returns the state of the error
	 * @return the state
	 */
	public String state()
	{
		return this.state;
	}
	
}
